package com.rc.saas.tenant.service.operator;

import com.rc.saas.tenant.mapper.operator.TenantOperatorOpenServiceMapper;
import com.rc.saas.tenant.model.operator.TenantOperatorOpenService;
import com.rc.saas.tenant.model.operator.TenantOperatorOpenServiceExample;
import com.rc.saas.tenant.model.tenant.TenantOpenService;
import com.rc.saas.tenant.model.tenant.TenantOpenServiceExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * Created by Sven on 2021/08/19
 */
@Service
public class TenantOperatorOpenServiceServiceImpl implements TenantOperatorOpenServiceService {
    @Autowired
    private TenantOperatorOpenServiceMapper tenantOperatorOpenServiceMapper;

    @Override
    public TenantOperatorOpenServiceMapper getMapper() {
        return tenantOperatorOpenServiceMapper;
    }

    @Override
    public TenantOperatorOpenService selectByTypeCode(String tenantOperatorCode, String serviceTypeCode) {
        TenantOperatorOpenServiceExample example = new TenantOperatorOpenServiceExample();
        example.createCriteria().andTenantOperatorCodeEqualTo(tenantOperatorCode).andServiceTypeCodeEqualTo(serviceTypeCode);
        List<TenantOperatorOpenService> list = tenantOperatorOpenServiceMapper.selectByExample(example);
        if (!CollectionUtils.isEmpty(list)) {
            return list.get(0);
        }
        return null;
    }
}
